import streamlit as st
from index import authenticator,save
from streamlit_authenticator.utilities.exceptions import ForgotError
                                                          
def forgot_username():
    try:
        (username_of_forgotten_username,
            email_of_forgotten_username) = authenticator.forgot_username()
        if username_of_forgotten_username:
            st.success('Username sent securely')
            save()
        elif not username_of_forgotten_username:
            st.error('Email not found')
    except ForgotError as e:
        st.error(e)